package com.cn.delan.jdbc.mssql;

import javax.sql.DataSource;

import com.cn.delan.jdbc.JDBCUtil;

public class MSSQLUtil extends JDBCUtil{

	public MSSQLUtil(DataSource dataSource) {
		super(dataSource);
	}

	@Override
	protected String compile(String sql) {
		String compileSQL = "";
		//获取翻页器的起始编码和终止编码
		int startNo = this.getPage().getStartNo();
		int endNo = this.getPage().getEndNo();
		compileSQL = sql.replace("select ", "select top "+endNo+" ___t=0,");
		compileSQL = "select * from (select row_number()over(order by ___t) ___rowNo, * from ("+compileSQL+") as _temp_table ) as __temp_table where ___rowNo>"+startNo;
		return compileSQL;
	}

}
